home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Circle out.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  1.9 KB  |  58 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define    gap            4        /* difference between one radius and the next */
  15. #define CorrectTime 2
  16.  
  17. void CircleOut(GrafPtr);
  18.  
  19. /* Make a circular region and use it as the mask in CopyBits.  Lots of overlap,
  20.    but masked by timing correction.  If you want to optimize it, look at the
  21.    donut region code in "Circle in.c" */
  22.    
  23. void CircleOut(GrafPtr sourceGrafPtr)
  24. {
  25.     Rect        theRect;
  26.     int            cx, cy;
  27.     RgnHandle    curregion;
  28.     
  29.     cx = MAIN_WINDOW_WIDTH / 2;
  30.     cy = MAIN_WINDOW_HEIGHT / 2;
  31.     
  32.     theRect.left=cx-gap;         /* circumscribing rectangle for circle */
  33.     theRect.right=cx+gap;
  34.     theRect.top=cy-gap;
  35.     theRect.bottom=cy+gap;
  36.     
  37.     curregion=NewRgn();
  38.     
  39.     do
  40.     {
  41.         StartTiming();
  42.         SetEmptyRgn(curregion);
  43.         OpenRgn();
  44.             FrameOval(&theRect);   /* the circle region */
  45.         CloseRgn(curregion);
  46.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  47.                 &theRect, &theRect, 0, curregion);
  48.         theRect.left-=gap;        /* make the rect bigger (and thus the circle) */
  49.         theRect.right+=gap;
  50.         theRect.top-=gap;
  51.         theRect.bottom+=gap;
  52.         TimeCorrection(CorrectTime);
  53.     }
  54.     while (theRect.right-theRect.left<=592);   /* (2 x || (cx,cy) ||) + a little */
  55.     
  56.     DisposeRgn(curregion);
  57. }
  58.